<%--
  - Author		:	이 영호(Youngho Lee)	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript">
			$(function(){
				$(".popupWrap").draggable({ cursor: "pointer", handle: ".pTitle" });
			});
			
			function validation(){
				try{
					with(document.frm){
						if((log.value).replace(/\s/g, '') == ""){
							alert("[검증로그]은 필수 입력 항목입니다.");
							log.focus();
							return false;
						}
						if((opinion.value).replace(/\s/g, '') == ""){
							alert("[분석의견]은 필수 입력 항목입니다.");
							opinion.focus();
							return false;
						}
						<c:if test="${empty vertification.testResultFile}">
							if((resultFile.value).replace(/\s/g, '') == ""){
								alert("[테스트 결과서]은 필수 입력 항목입니다.");
								resultFile.focus();
								return false;
							}
						</c:if>
					}
				}catch(err){
					alert(err);
					return false;	
				}
				
				if(! confirm("저장 하시겠습니까?")){
					return false;
				}
				
				return true;
			}
		</script>
	</head>
	<body>
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="contMenuTitle">
					<img src="<c:url value="${dirImages}/subtit_03.gif" />" title="검증 결과 조회" alt="검증 결과 조회">
				</div>
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="검증결과" alt="검증결과" > 
					<c:choose>
						<c:when test="${param.type eq 'pay'}">
							결제기 검증
						</c:when>
						<c:otherwise>
							애플릿 검증
						</c:otherwise>
					</c:choose>
				</div>
				<table class="formTbl" style="table-layout:fixed;">
					<colgroup>
						<col width="130px">
						<col width="250px">
						<col width="130px">
						<col width="*">
					</colgroup>
					<tbody>
						<tr>
							<th>신청기관명</th>
							<td>${vertification.bizName}</td>
							<th>검증분야</th>
							<td>
								<c:choose>
									<c:when test="${vertification.type eq 1}">애플릿 검증</c:when>
									<c:when test="${vertification.type eq 2}">결제기 검증</c:when>
									<c:otherwise>
										${vertification.type}
									</c:otherwise>
								</c:choose>
							</td>
						</tr>
						<tr>
							<th>신청자 ID</th>
							<td>
								${vertification.createdId}
								<%--
								<input type="button" class="btn btn_object_add" value="" onclick="javascript:$('.pUser').show();" />
								--%>
							</td>
							<th>기간</th>
							<td>
								<c:catch var="e">
									<fmt:parseDate var="createdTime" pattern="yyyy-MM-dd HH:mm:ss" value="${vertification.createdTime}" />
									<fmt:formatDate value="${createdTime}" pattern="yyyy.MM.dd" />
								</c:catch>
								<c:if test="${not empty e}">
									${vertification.createdTime}
								</c:if>
							</td>
						</tr>
						<tr>
							<th>검증단계</th>
							<td>
								<%-- 검증 상태 (-1:오류, 0:검증 신청, 1:진행중, 2:성공) --%>
								<c:choose>
									<c:when test="${vertification.status eq -1}">검증 오류</c:when>
									<c:when test="${vertification.status eq 0}">검증 신청</c:when>
									<c:when test="${vertification.status eq 1}">검증 중</c:when>
									<c:when test="${vertification.status eq 2}">검증 완료</c:when>
									<c:otherwise>
										${vertification.status}
									</c:otherwise>
								</c:choose>
							</td>
							<th>애플릿의 AID</th>
							<td>${vertification.aid}</td>
						</tr>
						<tr>
							<th>CAP 파일 업로드</th>
							<td style="word-break:break-all">
								<fmt:message key="file.capFile.viewUrl" var="viewUrl" />
								<a href="${vertification.cap}" target="_blank">${fn:replace(vertification.cap, viewUrl, '')}</a>
							</td>
							<th>테스트 단말 선택</th>
							<td>${vertification.testDevice}</td>
						</tr>
					</tbody>
				</table>
				<form name="frm" method="post" enctype="multipart/form-data" action="<c:url value="/backoffice/result/detail.do" />" onsubmit="return validation();">
					<input type="hidden" name="fAct" value="modify" />
					<input type="hidden" name="idx" value="${vertification.idx}" />
					<table class="formTbl" style="margin-top: 10px;width:748px;">
						<colgroup>
							<col width="130px">
							<col width="*">
						</colgroup>
						<tbody>
							<tr>
								<th width="130px">검증로그</th>
								<td style="width:618">
									<textarea name="log" maxlength="500" style="width: 585px; height: 160px;margin: 5px 0;">${vertification.log}</textarea>
								</td>
							</tr>
							<tr>
								<th width="130px">분석의견</th>
								<td style="width:618">
									<textarea name="opinion" maxlength="500" style="width: 585px; height: 160px;margin: 5px 0;">${vertification.opinion}</textarea>
								</td>
							</tr>
							<tr>
								<th width="130px">테스트 결과서</th>
								<td>
									<table style="width:618px;">
										<tr>
											<td width="200"><input type="file" name="resultFile" /></td>
											<td width="">
												<c:if test="${not empty vertification.testResultFile}">
													테스트결과서가 있습니다. 다운로드하시겠습니까?<br />
													<input type="button" value="테스트결과서 다운로드" onclick="javascript:location.href='${vertification.testResultFile}';">
												</c:if>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<th width="130px">검증결과</th>
								<td style="width:618">
									<select name="status">
										<option value="1" <c:if test="${vertification.status eq 1}"> selected="selected" </c:if>>검증 중</option>
										<option value="2" <c:if test="${vertification.status eq 2}"> selected="selected" </c:if>>검증 완료</option>
										<option value="-1" <c:if test="${vertification.status eq -1}"> selected="selected" </c:if>>검증 오류</option>
									</select>
								</td>
							</tr>
						</tbody>
					</table>
					<div class="btnWrap rightBtnWrap">
						<input type="submit" class="btn btn_ok" alt="확인" title="확인" value="">
					</div>
					<div class="popupWrap pUser" style="display: none;">
						<div class="pTitle">
							신청자 ID
						</div>
						<div class="pCont">
							<table class="listTbl">
								<thead>
									<tr>
										<th>번호</th>
										<th>ID</th>
										<th>이름</th>
										<th class="lastTh">업체명</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${userList}" var="user" varStatus="stat">
										<c:if test="${user.id ne vertification.createdId}">
											<tr>
												<td>
													<input type="checkbox" name="viewer" <c:if test="${fn:contains(vertification.viewer, user.id)}"> checked="checked" </c:if> value="${user.id}" />
												</td>
												<td><c:out value="${user.id}" /></td>
												<td><c:out value="${user.name}" /></td>
												<td><c:out value="${user.bizNm}" /></td>
											</tr>
										</c:if>
									</c:forEach>
								</tbody>
							</table>
						</div>
						<div class="btnWrap centerBtnWrap">
							<input type="button" class="btn btn_revision" alt="수정" title="수정" onclick="javascript:$('.pUser').hide();">
						</div>
					</div>
				</form>
				<br />
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="검증이력" alt="검증이력" > 검증이력
				</div>
				<table class="listTbl linked">
					<thead>
						<tr>
							<th>회차</th>
							<th>신청일자</th>
							<th>신청기관</th>
							<th>신청ID</th>
							<th>애플릿 AID</th>
							<th>검증 단계</th>
							<th>CAP 파일</th>
							<th>TEST 단말 선택</th>
							<th class="lastTh">접수 상태</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>1</td>
							<td>
								<c:catch var="e">
									<fmt:parseDate var="createdTime" pattern="yyyy-MM-dd HH:mm:ss" value="${vertification.createdTime}" />
									<fmt:formatDate value="${createdTime}" pattern="yyyy.MM.dd" />
								</c:catch>
								<c:if test="${not empty e}">
									${vertification.createdTime}
								</c:if>
							</td>
							<td>${vertification.bizName}</td>
							<td>${vertification.createdId}</td>
							<td>${vertification.aid}</td>
							<td>
								<%-- 검증 상태 (-1:오류, 0:검증 신청, 1:진행중, 2:성공) --%>
								<c:choose>
									<c:when test="${vertification.status eq -1}">검증 오류</c:when>
									<c:when test="${vertification.status eq 0}">검증 신청</c:when>
									<c:when test="${vertification.status eq 1}">검증 중</c:when>
									<c:when test="${vertification.status eq 2}">검증 완료</c:when>
									<c:otherwise>
										${vertification.status}
									</c:otherwise>
								</c:choose>
							</td>
							<td><a href="${vertification.cap}" target="_blank"><img class="btn"  src="<c:url value="${dirImages}/bt_file_add.gif" />" title="파일 첨부" alt="파일 첨부" /></a></td>
							<td>${vertification.testDevice}</td>
							<td>
								<%-- 검증 상태 (-1:오류, 0:검증 신청, 1:진행중, 2:성공) --%>
								<c:choose>
									<c:when test="${vertification.status eq -1 or vertification.status eq 2}">
										<img class="btn"  src="<c:url value="${dirImages}/icon_end.gif" />" title="처리중" alt="처리중" />
									</c:when>
									<c:otherwise>
										<img class="btn"  src="<c:url value="${dirImages}/icon_ing.gif" />" title="처리중" alt="처리중" />
									</c:otherwise>
								</c:choose>
							</td>
						</tr>
						<c:forEach items="${vertificationHistory}" var="vHistory" varStatus="idx">
							<tr>
								<td>${idx.count + 1 }</td>
								<td>
									<c:catch var="e">
										<fmt:parseDate var="createdTime" pattern="yyyy-MM-dd HH:mm:ss" value="${vHistory.createdTime}" />
										<fmt:formatDate value="${createdTime}" pattern="yyyy.MM.dd" />
									</c:catch>
									<c:if test="${not empty e}">
										${vHistory.createdTime}
									</c:if>
								</td>
								<td>${vHistory.bizName}</td>
								<td>${vHistory.createdId}</td>
								<td>${vHistory.aid}</td>
								<td>
									<%-- 검증 상태 (-1:오류, 0:검증 신청, 1:진행중, 2:성공) --%>
									<c:choose>
										<c:when test="${vHistory.status eq -1}">검증 오류</c:when>
										<c:when test="${vHistory.status eq 0}">검증 신청</c:when>
										<c:when test="${vHistory.status eq 1}">검증 중</c:when>
										<c:when test="${vHistory.status eq 2}">검증 완료</c:when>
										<c:otherwise>
											${vHistory.status}
										</c:otherwise>
									</c:choose>
								</td>
								<td><a href="${vHistory.cap}" target="_blank"><img class="btn"  src="<c:url value="${dirImages}/bt_file_add.gif" />" title="파일 첨부" alt="파일 첨부" /></a></td>
								<td>${vHistory.testDevice}</td>
								<td>
									<%-- 검증 상태 (-1:오류, 0:검증 신청, 1:진행중, 2:성공) --%>
									<c:choose>
										<c:when test="${vHistory.status eq -1 or vHistory.status eq 2}">
											<img class="btn"  src="<c:url value="${dirImages}/icon_end.gif" />" title="처리중" alt="처리중" />
										</c:when>
										<c:otherwise>
											<img class="btn"  src="<c:url value="${dirImages}/icon_ing.gif" />" title="처리중" alt="처리중" />
										</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
	</body>
</html> 